package payroll.classfication;

import java.util.LinkedHashMap;
import java.util.Map;

public class CommissionedClassification implements PaymentClassfication{

    private double salary;
    private double commissionRate;
    private Map<String, SalesReceipt> salesReceipts=new LinkedHashMap<>();

    public CommissionedClassification(double salary, double commissionRate) {
        this.salary = salary;
        this.commissionRate = commissionRate;
        
    }

    public double getSalary() {
       return salary;
    }

    public double getCommissionRate() {
        return commissionRate;
        

}

    public SalesReceipt getSalesReceiptofDate(String date) {
        return salesReceipts.get(date);

        
    }

    public void addSalesReceipt(SalesReceipt sr) {
        
        salesReceipts.put(sr.getDate(), sr);
    }
    @Override
    public double calculatePay() {
       double total=0;
        for (SalesReceipt sr : salesReceipts.values()) {
            total += sr.getAmount() ;
        }
        return salary + total * commissionRate;

    }
}